<!--# layout("/common/layout.html",{"jsBase":"/js/activity/activityMain/"}){ -->

<form class="layui-form layui-form-pane" id="addForm"  lay-filter="editform">
    <input type="hidden" name="actId" id="actId">
    <br>
    <div class="layui-row">
        <div class="layui-form-item">
            <div class="layui-inline">
            <label class="layui-form-label">活动名称</label>
				<div class="layui-input-inline">
                    <input type="text" name="actName" id="actName" autocomplete="off" maxlength="50" class="layui-input" lay-verify="required">
				</div>
            </div>


        </div>
    </div>

    <div class="layui-row">
        <div class="layui-form-item">

            <div class="layui-inline">
                <label class="layui-form-label">开始时间</label>
                <div class="layui-input-inline">
                    <input type="text" name="startTime"  id="startTime" autocomplete="off" class="layui-input input-time" lay-verify="required">
                </div>
            </div>

            <div class="layui-inline">
                <label class="layui-form-label">截止时间</label>
                <div class="layui-input-inline">
                    <input type="text" name="endTime"  id="endTime" autocomplete="off" class="layui-input input-date" lay-verify="required">
                </div>
            </div>

        </div>
    </div>
    <div class="layui-row">
        <div class="layui-form-item">
            <div class="layui-inline">
            <label class="layui-form-label">活动类型</label>
				<div class="layui-input-inline">
                    <select class="select" name="actType" id="actType"  promtion="请选择" lay-verify="required">
                        <option value="">请选择</option>
                        <option value="1">助力高考</option>
                    </select>
				</div>
            </div>
            <div class="layui-inline">
            <label class="layui-form-label">上线状态</label>
				<div class="layui-input-inline">
                    <select class="select" name="actStatus" id="actStatus"  promtion="请选择" lay-verify="required">
                        <option value="">请选择</option>
                        <option value="1">新增</option>
                        <option value="2">上线</option>
                        <option value="3">下线</option>
                    </select>
				</div>
            </div>
        </div>
    </div>

    <div class="layui-row">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">助力链接</label>
                <div class="layui-input-inline">
                    <input type="text" name="url" id="url" autocomplete="off" maxlength="50" class="layui-input" lay-verify="required" style="width: 590px">
                </div>
             </div>
        </div>
    </div>
    <div class="layui-row">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">活动说明</label>
                <div class="layui-input-block" style="width:590px;">
                    <textarea name="explain"  id="explain" placeholder="请输入" rows="6" class="layui-textarea" lay-verify="required" ></textarea>
                </div>
            </div>
        </div>
    </div>
    <div class="layui-row">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">助力说明</label>
                <div class="layui-input-block" style="width:590px;">
                    <textarea name="ruleExplain"  id="ruleExplain" placeholder="请输入" rows="6" class="layui-textarea" lay-verify="required" ></textarea>
                </div>
            </div>
        </div>
    </div>
    <layui:submitButtons id="addButton" />
</form>
<!--#} -->
<script>
layui.extend({
    loading: '../../../plugins/layui_extends/loading/loading',
}).define([ 'form', 'laydate', 'table','loading','activityMainApi'], function(exports) {
    var form = layui.form;
    var activityMainApi = layui.activityMainApi;
    var index = layui.index;
    var isNew = true;
    var laydate = layui.laydate;
    <!--# if(!(isEmpty(activityMainJson))){  -->
    isNew = false;
    <!--# } -->

    laydate.render({
        elem: '#startTime'
        ,type: 'datetime'
    });

    laydate.render({
        elem: '#endTime'
        ,type: 'datetime'
    });

    var view = {
        init:function(){
            Lib.initGenrealForm($("#addForm"),form);
            this.initSubmit();
        },
        initSubmit:function(){
            $("#addButton").click(function(){
                // $("#addButton").hide();
                // $("#addButton-loading").show();
                // $("#addButton-loading").loading();

                var startTime=$("#startTime").val();
                var start=new Date(startTime.replace("-", "/").replace("-", "/"));
                var endTime=$("#endTime").val();
                var end=new Date(endTime.replace("-", "/").replace("-", "/"));
                var date = new Date();
                if(end<=date ){
                    Common.info("截止时间必须大于当前时间");
                    return ;
                }
                if(end<=start){
                    Common.info("结束时间必须大于开始时间");
                    return ;
                }
                form.on('submit(form)', function(){
                    activityMainApi.saveForm(isNew,$('#addForm'),function(){
                        parent.window.dataReload();
                        Common.info("保存成功");
                        Lib.closeFrame();
                    });
                });
            });

            $("#addButton-cancel").click(function(){
                Lib.closeFrame();
            });
        }

    }
    view.init();
    <!--# if(!(isEmpty(activityMainJson))){  -->
    var formJson = ${activityMainJson};
    form.val("editform",formJson);
    <!--# } -->
});
</script>
